<!---Not in cfscript because I'm lazy and I copied from my other project--->
<cfcomponent output="true">

	<cfproperty name="PageTitle" type="string" />
	<cfproperty name="JSList" type="string" />
	<cfproperty name="CSSList" type="string" />
    <cfproperty name="PageContent" type="string" />
    <cfproperty name="CSSLayout" type="string" />
    <cfproperty name="JavaScript" type="string" />
    <cfproperty name="showSideBar" type="string" default="0" />
    
    <cffunction name="init" access="public" returntype="layout" output="false">
        <cfargument name="PageTitle" type="string" required="no" default="EPAR">
        <cfargument name="JSList" type="string" required="no" default="">
        <cfargument name="CSSList" type="string" required="no" default="">
        <cfargument name="PageContent" type="string" required="no" default="Hello World!">
        <cfargument name="JavaScript" type="string" required="no" default="Hello World!">
        
        <cfscript>                        
            setPageTitle(arguments.PageTitle);  
            setJSList(arguments.JSList);    
            setCSSList(arguments.CSSList); 
            setPageContent(arguments.PageContent);
            setJavaScript(arguments.JavaScript);
            this.showSideBar = 0;
            return this;             
        </cfscript>
    </cffunction>
    
    <cffunction name="setJavaScript" access="public" output="false" returntype="void">
        <cfargument name="JavaScript" type="string" required="true" />
        <cfset this.JavaScript = arguments.JavaScript />
        <cfreturn />
    </cffunction>
    
    <cffunction name="getJavaScript" access="public" output="false" returntype="string">
        <cfreturn this.JavaScript />
    </cffunction>
    
    <cffunction name="setCSSLayout" access="public" output="false" returntype="void">
        <cfargument name="CSSLayout" type="string" required="true" />
        <cfset this.CSSLayout = arguments.CSSLayout />
        <cfreturn />
    </cffunction>
    
    <cffunction name="getCSSLayout" access="public" output="false" returntype="string">
        <cfreturn this.CSSLayout />
    </cffunction>
    
	<cffunction name="getPageTitle" access="public" output="false" returntype="string">
		<cfreturn this.PageTitle />
	</cffunction>

	<cffunction name="setPageTitle" access="public" output="false" returntype="void">
		<cfargument name="PageTitle" type="string" required="true" />
		<cfset this.PageTitle = arguments.PageTitle />
		<cfreturn />
	</cffunction>


	<cffunction name="getJSList" access="public" output="false" returntype="string">
		<cfreturn this.JSList />
	</cffunction>


	<cffunction name="setJSList" access="public" output="false" returntype="void">
		<cfargument name="JSList" type="string" required="true" />
		<cfset this.JSList = arguments.JSList />
		<cfreturn />
	</cffunction>


	<cffunction name="getCSSList" access="public" output="false" returntype="string">
		<cfreturn this.CSSList />
	</cffunction>


	<cffunction name="setCSSList" access="public" output="false" returntype="void">
		<cfargument name="CSSList" type="string" required="true" />
		<cfset this.CSSList = arguments.CSSList />
		<cfreturn />
	</cffunction>
    
    
    <cffunction name="setPageContent" access="public" output="false" returntype="void">
        <cfargument name="PageContent" type="string" required="true" />
        <cfset this.PageContent = arguments.PageContent />
        <cfreturn />
    </cffunction>
    
    <cffunction name="getPageContent" access="public" output="false" returntype="string">
        <cfreturn this.PageContent />
    </cffunction>
    

	<cffunction name="html" access="public" output="true" returntype="Any">        
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><cfoutput>#this.PageTitle#</cfoutput></title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta content="no-cache" />
        
        <link href="/scfApps/css/scfAppsGeneral.css" rel="stylesheet" type="text/css" />
        <link href="/scfApps/css/scfApps.css" rel="stylesheet" type="text/css" />
        <link href="/scfApps/css/scfAppsYellow.css" rel="stylesheet" type="text/css" />
        <!---to change template color, add either scfAppsYellow.css, scfAppsBlue.css, or scfAppsGreen.css--->
        <link href="/<cfoutput>#session.rootDir#</cfoutput>/static/css/template.css" rel="stylesheet" type="text/css" />
        <cfif ListLen(this.CSSList) gt 0>
            <cfloop list="#this.CSSLIst#" index="css" delimiters=",">
                <link href="<cfoutput>#css#</cfoutput>" rel="stylesheet" type="text/css" />
            </cfloop>
        </cfif>
                
        <script language="Javascript" type="text/javascript" src="/jquery/jquery-1.4.2.min.js"></script>
        <cfif ListLen(this.JSList) gt 0>
            <cfloop list="#this.JSList#" index="js" delimiters=",">             
                <script language="Javascript" type="text/javascript" src="<cfoutput>#js#</cfoutput>" ></script>             
            </cfloop>
        </cfif>
             	
        <script language="Javascript" type="text/javascript">
            <cftry>
            	#this.JavaScript()#            
            <cfcatch type="Any" >
            </cfcatch>
            </cftry>
        </script>
        
        <style>
            .hideme{display:none;}
            a.important{color:red}
        </style>     
        </head>              
        
        <body>
            <div id="outer">
                <div id="header">
                    <h1><span class="headerColor">SCF</span> #APPLICATION.HeaderName#</h1>
                    <h2>#APPLICATION.version#</h2>
                </div>
                <div id="statusBar">
                    <div id="statusBarLeft">Welcome #SESSION.myUserInfo.FirstName# #SESSION.myUserInfo.LastName#</div>
                    <div id="statusBarRight"></div>
                </div>                    
                
                <div id="menu_wrapper" class="black">
                <div class="left"></div>
                    <ul id="menu">
                        <li><a href="viewData.cfm">View Data</a></li>
                        <li><a href="editData.cfm">Edit Data</a></li>
                        <li><a href="hr/queue.cfm">HR Queue</a></li>
                        <li><a href="finance/queue.cfm">Finance Queue</a></li>
                        <li><a href="reports/">Reports</a></li>
                        <li><a href="logout.cfm">Logout</a></li>
                    </ul>
                </div>
                    
                <div id="content" style="margin-top: 10px;">
                    <cfif this.showSideBar eq 1>
                        <div id="sideBarRight">
                            <h2>Options</h2>
                            <div id="sideBarLinks">
                                <a href="printdata.cfm">PDF my data</a>
                                <a href="emaildata.cfm">Email my data</a>
                                <a href="slsdata.cfm">Excel my data</a>
                            </div>
                        </div>
                    </cfif>
                    <div id="main" class="noSidebar"><!---If you take out sidebars, add a class on the main of either leftSidebar, rightSidebar or noSidebar--->
                        <br />
                        <cfscript>
                            if( SESSION.IsPasswordGood == 1){
                                writeOutput(this.PageContent());
                            }else{
                                writeOutput(userLogin());
                            }                                
                        </cfscript>
                    </div>
                </div>
                <div id="footer">
                    <p id="legal">&copy;2007-#dateformat(now(),"YY")# Southcentral Foundation.</p>
                </div>
            </div>
        </body>
        </html>
        
        <cfreturn />
    </cffunction>
    
    
    <cffunction name="pdf" access="public" output="true" returntype="Any">
        
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><cfoutput>#this.PageTitle#</cfoutput></title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta content="no-cache" />
        
        <link href="/scfApps/css/scfAppsGeneral.css" rel="stylesheet" type="text/css" />
        <!---<link href="/scfApps/css/scfApps.css" rel="stylesheet" type="text/css" />--->
        <!---<link href="/scfApps/css/scfAppsYellow.css" rel="stylesheet" type="text/css" />--->
        <!---to change template color, add either scfAppsYellow.css, scfAppsBlue.css, or scfAppsGreen.css--->
        <!---<link href="/<cfoutput>#session.rootDir#</cfoutput>/static/css/template.css" rel="stylesheet" type="text/css" />--->
        <cfif ListLen(this.CSSList) gt 0>
            <cfloop list="#this.CSSLIst#" index="css" delimiters=",">
                <link href="<cfoutput>#css#</cfoutput>" rel="stylesheet" type="text/css" />
            </cfloop>
        </cfif>
                
        <script language="Javascript" type="text/javascript" src="/jquery/jquery-1.4.2.min.js"></script>
        <cfif ListLen(this.JSList) gt 0>
            <cfloop list="#this.JSList#" index="js" delimiters=",">             
                <script language="Javascript" type="text/javascript" src="<cfoutput>#js#</cfoutput>" ></script>             
            </cfloop>
        </cfif>
        
          
        </head>
        <body>        
                                
            <div id="main" class="rightSidebar">           
                <br />
                <cfscript>
                    if( SESSION.IsPasswordGood == 1){
                        writeOutput(this.PageContent());
                    }else{
                        writeOutput(userLogin());
                    }
                </cfscript>
            </div>
        
        </body>
        </html>      
        
        <cfreturn />
    </cffunction>
    
    
    
    <cffunction name="userLogin" access="public" output="true" returntype="any">
        <cfform name="loginForm" >
            <script >
                function loginMessage(redirect, auth){
                    var loginMsg = function(){
                        $("##success_msg").remove();
                        clearTimeout(timeout_index);
                        delete timeout_index;
                        if(auth == 1){ location.href = redirect };
                    };
                    if(auth == 1){ 
                        timeout_index = setTimeout(loginMsg, 1000);
                    }else{
                        timeout_index = setTimeout(loginMsg, 4500);
                    }
                    $(window).unload( function (){
                        if( typeof(timeout_index) != 'undefined' ){  }
                    });        
                }
                
                function submitLogin(obj){
                    var data = {};   
                    $.ajax({
                        type:'POST', url:$("##action").val(), dataType: 'json', async: true, data: obj,
                        success: function(json){
                            data = json;
                            if( data.AUTH == 1 ){
                                $("##login").after(' <span class="highlight" id="success_msg">Login was successful!</span>');
                            }else{
                                $("##login").after(' <span class="important" id="success_msg">Login was not successful!</span>');
                            }
                        },
                        complete: function(){$("##progress").hide(); loginMessage('index.cfm', data.AUTH);},
                        error: function(){ return false; }
                    });
                }
                
                function bindelements(){
                    $('##user_password').keypress(function(event) {
                      if (event.which == '13') {
                         event.preventDefault();
                         $("##progress").show();      
                        var retObj = { username: $('##user_name').val(), password: $('##user_password').val() };
                        submitLogin(retObj);
                       }
                    });
                         
                }
            
                $(function(){
                    bindelements();
                    $('##login').click(function(){
                        $("##progress").show();      
                        var retObj = { username: $('##user_name').val(), password: $('##user_password').val() };
                        submitLogin(retObj);
                    });        
                });        
            </script>
            <cfoutput>
                <table class="dataTable">
                    <thead>
                        <tr>
                            <th>Login</th>
                            <th>Password</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>#UCase(cgi.AUTH_USER)# <cfinput type="hidden" name="user_name" value="#cgi.AUTH_USER#"/></td>
                            <td><cfinput type="password" size="30" name="user_password" /></td>
                        </tr>
                    </tbody>
                </table>
                <cfinput class="btn" type="button" value="Login" name="login">
                <img src="/#session.rootDir#/images/rotator.gif" align="absmiddle" style="display:none;" id="progress"/>
                <cfinput type="hidden" name="key" value="#APPLICATION.ENCRYPTION_KEY#"/>
                <cfinput type="hidden" name="action" value="controller/LoginHandler.cfm?#SESSION.URLTOKEN#"/>
            </cfoutput>
        </cfform>
    </cffunction>
    
    
</cfcomponent>